Tool Window (code)
Volume Number: 4
Issue Number: 12
Column Tag: C Workshop
Tool Window Wanager (code)
{1}
Listing: TWindow.c
/*
* TWindows.c
*
* C source of an extended Window Manager that
* supports tool windows; these are windows
* that always float on top, for palettes and
* tools.
*
* Written in MPW C 2.0
*
* Copyright Thomas Fruin 1988
* All rights reserved.
*/
/*
* T O O L B O X I N C L U D E S
*/
#include
#include
#include
#include
#include
#include
#include
#include
/*
* T O O L B O X D E F I N I T I O N S
*/
#define GrayRgn (*(RgnHandle *)0x9EE)
#define WindowList (*(WindowPeek *)0x9D6)
/*
* D E F I N I T I O N S
*/
/* Defines LONGINT, INTEGER, the windowKind
constants and the externally callable
TWindow Manager functions. */
#include
/* Result codes describing window positions, as
returned by the function GetWPosition. */
#define alone 0
#define beforeDialog 1
#define beforeSystem 2
#define beforeTool 3
#define beforeDocument 4
#define behindFrontSystem 5
#define betweenTools 6
#define behindTools 7
#define behindSystem 8
#define betweenDocuments 9
/* Miscellaneous */
#define deactivFlag 0
#define noDrag -32768
#define invisible false
#define curVersion 1
#define postponeCalc true
#define normalCalc false
/*
* T Y P E S
*/
/* The WINDData structure matches the structure
of a WIND resource in a resource file. It
is used to access the various fields of the
WIND resource after it has been read in from
the file. */
struct WINDRecord
{
Rect boundsRect;
INTEGER procID;
Boolean visible;
char filler1;
Boolean goAwayFlag;
char filler2;
LONGINT refCon;
Str255 title;
};
typedef struct WINDRecord WINDData;
typedef struct WINDRecord *WINDPtr;
typedef struct WINDRecord **WINDHandle;
/* The WDEFHeader structure matches the
structure of the (optional) header of a
window definition procedure resource. */
struct WDEFRecord
{
INTEGER branch;
INTEGER flags;
LONGINT type;
INTEGER ID;
INTEGER version;
};
typedef struct WDEFRecord WDEFHeader;
typedef struct WDEFRecord *WDEFPtr;
typedef struct WDEFRecord **WDEFHandle;
/*
* G L O B A L S
*/
static WindowPeek toBeActivated,
toBeDeactivated,
frontToolWindow,
backToolWindow,
frontDocWindow;
static RgnHandle firstRgn,
secondRgn;
static SysEnvRec theWorld;
/*
* T I N I T W I N D O W S
*/
void
TInitWindows()
{
OSErr err;
frontToolWindow =
backToolWindow =
frontDocWindow =
toBeDeactivated =
toBeActivated = nil;
firstRgn = NewRgn();
secondRgn = NewRgn();
err = SysEnvirons( curVersion, &theWorld );
}
/*
* T G E T N E W W I N D O W
*/
TGetNewWindow( windowKind, windowID,
wStorage, behind )
INTEGER windowKind;
INTEGER windowID;